home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / os2 / os2nt.zip / SHOWPART.C < prev   
C/C++ Source or Header  |  1993-07-04  |  3KB  |  96 lines

  1. /**************************************************************************
  2.                            S H O W P A R T
  3.  
  4.   Show partition record data for 80 (first) drive.  Thanks to Steve
  5.   Behman for early version.
  6.  
  7.   Works equally by compiling with Microsoft or Borland:
  8.  
  9.     cl showpart.c
  10.   or
  11.     bcc showpart.c
  12.  
  13.   7/4/93        Dave Hillman
  14.                 CIS:      74045,1127
  15.                 Internet: dxh50@juts.ccc.amdahl.com
  16.  
  17. **************************************************************************/
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <dos.h>
  21. #include <string.h>
  22. #include <process.h>
  23. #include <bios.h>
  24.  
  25. typedef unsigned char Byte;
  26. typedef unsigned long Ulong;
  27. typedef struct
  28. {
  29.   Byte boot_ind;        // boot indicator.  0 or 0x80 if active
  30.   Byte beg_cchr[3];     // Beginning of partition Track sector & head
  31.   Byte system_ind;      // 0x06 is BIG DOS primary
  32.                         // 0x05 is Extended DOS
  33.                         // 0x07 is NT - NTFS
  34.                         // 0x0a is OS/2 Boot manager
  35.   Byte end_cchr[3];     // Ending of partition Track, sector and head
  36.   Ulong rel_sector;     // Starting sector number
  37.   Ulong num_sector;     // Length of partition in sectors
  38. } PartitionRecord;
  39.  
  40. typedef struct
  41. {
  42.   Byte bootStuff[ 0x1be ];
  43.   PartitionRecord par[ 4 ];
  44.   Byte endStuff[2];
  45. } BootRec;
  46.  
  47. union REGS in;
  48. struct SREGS seg;
  49.  
  50. #define AX in.x.ax
  51. #define BX in.x.bx
  52. #define ES seg.es
  53. #define CX in.x.cx
  54. #define DX in.x.dx
  55.  
  56. Byte buf[512];
  57.  
  58. /**************************************************************************
  59.                                M A I N
  60. **************************************************************************/
  61.  
  62. void main()
  63. {
  64.   int i;
  65.   BootRec *rec = (BootRec *)buf;
  66.   PartitionRecord *par = rec->par;
  67.   Byte far *p = ( Byte far *)buf;
  68.   int drive = 0;
  69.  
  70.   AX = 0x0201;                          /* read 1 sector. this will be
  71.                                            0x0301 to write */
  72.   BX = FP_OFF( p );                     /* into the record */
  73.   ES = FP_SEG( p );
  74.   CX = 0x0001;                          /* to/from track 0, sector 1 */
  75.   DX = 0x0080 + drive;                  /* in drive 80 (81 is the
  76.                                            second) */
  77.   int86x( 0x13, &in, &in, &seg );
  78.  
  79.   /* display the data to be sure we got it right */
  80.   for (i = 0; i < 4; i++)
  81.   {
  82.     printf( " %d:%d %02x %02x\n",
  83.         drive, i,
  84.         par[i].boot_ind,
  85.         par[i].system_ind );
  86.   }
  87.  
  88.   /*
  89.    * Do other work here such as writing the buffer to disk so it can
  90.    * be modified and written later. Or modified and written back to
  91.    * the boot sector.
  92.    */
  93.  
  94. } /* end main */
  95.  
  96.